-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MTG 1164 Apply showZeroBalance only for NFTs #368
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LBTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you! The only question is whether we need to modify any indexes
@StanChe nope, we should not. I've tested this query on nodes with Solana data and with that added condition it works same as without it. We are good there. |
Double checked explain analyze for final query, these changes actually increases execution time, from >100ms to ~3 seconds. First tests I did showed incorrect results. So it's better not to merge this PR at the moment. |
Latest commit adds improvements to SQL query. Also it adds 2 new indexes which also will improve selects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great change, let's ask others to revalidate as well. The limit should be fixed
@@ -0,0 +1,3 @@ | |||
CREATE INDEX fungible_tokens_fbt_owner_fbt_asset_fbt_balance_idx ON fungible_tokens (fbt_owner, fbt_asset, fbt_balance); | |||
|
|||
CREATE INDEX assets_ast_owner_type_ast_pubkey_idx ON assets_v3 (ast_owner_type, ast_pubkey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line please
@@ -0,0 +1,3 @@ | |||
CREATE INDEX fungible_tokens_fbt_owner_fbt_asset_fbt_balance_idx ON fungible_tokens (fbt_owner, fbt_asset, fbt_balance); | |||
|
|||
CREATE INDEX assets_ast_owner_type_ast_pubkey_idx ON assets_v3 (ast_owner_type, ast_pubkey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may also want to drop assets_v3_owner_type as it becomes obsolete
|
||
query_builder.push(" LIMIT "); | ||
if let Some(page_num) = page.filter(|&p| p > 1) { | ||
let lim = (page_num - 1) * limit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition is wrong. it's page_num*limit. You want to have 2000 records pre filtered for the second page. Also add a test for the second page of pagination of this request. The correct way to do it is you always get a 1-based page and multiply it by the limit
query_builder.push(direction); | ||
|
||
query_builder.push(" LIMIT "); | ||
if let Some(page_num) = page.filter(|&p| p > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as below
What
This PR adds condition to the JOIN SQL command which tells to join only rows with
ast_owner_type
field set totoken
. As a result fromfungible_tokens
table will be taken accounts which are related to fungible assets and not NFTs.Also this PR adds new integration test which checks if that JOIN works as expected.
IMPORTANT
Do not merge into main until #376 is merged into this branch